<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var operation = prompt('欢迎使用 1.加法，2.减法，3.乘法，4.除法')
        var one = prompt('第一个数字')
        var two = prompt('第二数字')

        function cal(operation, one, two) {
            if (operation == '1') {
                return parseFloat(one) + parseFloat(two);
            } else {
                return one - two;
            }
        }
        alert('计算结果为' + cal(operation, one, two))
    </script>
</body>

</html>